//
//  WBUploadManager.m
//  WeatherBar
//
//  Created by Frank on 2024/6/26.
//

#import "WBUploadManager.h"
#import "WBLogin01Model.h"
#import "WBLoc01Model.h"
#import "WBDev01Model.h"
#import "WBReg02Model.h"
#import "WBBcc01Model.h"
#import "WBPermission01Model.h"
#import "WBStart01Model.h"
#import "WBPush02Model.h"
#import "WBIdcard02Model.h"
#import "WBInstallModel.h"
#import "WBAcq01Model.h"
#import "WBAcq02Model.h"
#import "WBAcq03Model.h"

@implementation WBUploadManager

static WBUploadManager *var_instance;

+ (instancetype)wb_shareInstance {
    if (var_instance==nil) {
        var_instance = [[super allocWithZone:NULL] init];
    }
    return var_instance;
}
+ (id)allocWithZone:(struct _NSZone *)zone {
    return [WBUploadManager wb_shareInstance];
}

- (id)copyWithZone:(struct _NSZone *)zone {
    return [WBUploadManager wb_shareInstance];
}
+ (void)wb_destroyInstance {
    var_instance = nil;
}

+ (void)wb_uploadType:(WBUploadType)type {
    switch (type) {
        case WBUploadTypeLoc01: {
            NSDictionary *var_param = [WBLoc01Model wb_getParameter];
            [self wb_requestWithParam:var_param type:@"Loc01"];
        }
            break;
        case WBUploadTypeLogin01: {
            NSDictionary *var_param = [WBLogin01Model wb_getParameter];
            [self wb_requestWithParam:var_param type:@"Login01"];
        }
            break;
        case WBUploadTypeReg02: {
            NSDictionary *var_param = [WBReg02Model wb_getParameter];
            [self wb_requestWithParam:var_param type:@"Reg02"];
        }
            break;
        case WBUploadTypeDev01: {
            NSDictionary *var_param = [WBDev01Model wb_getParameter];
            [self wb_requestWithParam:var_param type:@"Dev01"];
        }
            break;
        case WBUploadTypeBcc01: {
            NSDictionary *var_param = [WBBcc01Model wb_getParameter];
            [self wb_requestWithParam:var_param type:@"Bcc01"];
        }
            break;
        case WBUploadTypePermission01: {
            NSDictionary *var_param = [WBPermission01Model wb_getParameter];
            [self wb_requestWithParam:var_param type:@"Permission01"];
        }
            break;
        case WBUploadTypeStart01: {
            NSDictionary *var_param = [WBStart01Model wb_getParameter];
            [self wb_requestWithParam:var_param type:@"Start01"];
        }
            break;
        case WBUploadTypeInstalls: {
            NSDictionary *var_param = [WBInstallModel wb_getParameter];
            [self wb_requestWithParam:var_param type:@"Installs"];
        }
            break;
        case WBUploadTypeIdcard02: {
            NSDictionary *var_param = [WBIdcard02Model wb_getParameter];
            [self wb_requestWithParam:var_param type:@"Idcard02"];
        }
            break;
        case WBUploadTypePush02: {
            NSDictionary *var_param = [WBPush02Model wb_getParameter];
            [self wb_requestWithParam:var_param type:@"Push02"];
        }
            break;
        case WBUploadTypeAcq01: {
            NSDictionary *var_param = [WBAcq01Model wb_getParameter];
            [self wb_requestWithParam:var_param type:@"Acq01"];
        }
            break;
        case WBUploadTypeAcq02: {
            NSDictionary *var_param = [WBAcq02Model wb_getParameter];
            [self wb_requestWithParam:var_param type:@"Acq02"];
        }
            break;
        case WBUploadTypeAcq03: {
            NSDictionary *var_param = [WBAcq03Model wb_getParameter];
            [self wb_requestWithParam:var_param type:@"Acq03"];
        }
            break;
        default:
            break;
    }
}

+ (void)wb_requestWithParam:(NSDictionary *)param type:(NSString *)type {
    NSDictionary *var_info = [WBInfoManager wb_shareInstance].var_businessInfo;
    NSString *var_url = [NSString stringWithFormat:@"sea/v1/metrics?appid=%@&zuid=%@&ek=1",[var_info valueForKey:@"appid"], [UIDevice wb_getZuid]];
    [WBBaseRequest postRequestWithMethodName:var_url parametersDic:param success:^(WBBaseRequest * _Nonnull operation, BOOL isSuccess, id  _Nonnull responseObject) {
        NSLog(@"------------%@\r\n", type);

    }];
}

@end
